class Text < Gtk::TextView

	def initialize
		super
		self.wrap_mode = Gtk::TextTag::WRAP_WORD
		self.set_size_request(0, 0)
		apply_config
		self.buffer.signal_connect('changed') { $main.dirty = true }
	end

	def apply_config
		self.modify_font(Pango::FontDescription.new($conf.font))
		self.modify_text(Gtk::STATE_NORMAL, $conf.fg)
		self.modify_base(Gtk::STATE_NORMAL, $conf.bg)
		self.width_request = $conf.text_width
	end

	def clear
		self.buffer.text = ''
	end

	def formatted_text
		return [self.buffer.text]
	end

	def formatted_text=(t)
		if t[0] == nil
			self.buffer.text = ''
		else
			self.buffer.text = t[0]
		end
	end

end
